import 'package:flutter/material.dart';

mixin MxGridView {
  ///设定滚动方向，也就是主方向
  Axis mxScrollDirection = Axis.vertical;

  ///数量
  int mxItemCount = 3;

  ///次方向上显示几个
  int mxCrossAxisCount = 2;

  ///主方向
  double mxMainSpacing = 0;

  ///次方向
  double mxCrossSpacing = 0;

  ///网络布局
  Widget mxBuildGridView(BuildContext context) {
    return MediaQuery.removePadding(
      context: context,
      removeTop: true,
      child: GridView.builder(
        scrollDirection: mxScrollDirection,
        itemCount: mxItemCount,
        gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
          crossAxisCount: mxCrossAxisCount,
          mainAxisSpacing: mxMainSpacing,
          crossAxisSpacing: mxCrossSpacing,
        ),
        itemBuilder: (BuildContext context, int index) {
          return mxItemBuilder(context, index);
        },
      ),
    );
  }

  ///item布局
  Widget mxItemBuilder(BuildContext context, int index) {
    return Container(
      color: Colors.red,
    );
  }
}
